package com.hsteach.framework.feign;

import com.hsteach.common.exception.ServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 用户角色枚举
 */
@Getter
@AllArgsConstructor
public enum IdentityEnum {
    ADMIN("00", "管理员", null),
    EDUGOV_TEACHER("10", "区域老师", null),
    TEACHER("20", "教职工", "2"),
    PARENT("40", "家长", "3"),
    ;

    private String code;
    private String name;
    private String personType;

    public static IdentityEnum getByCode(String code) {
        IdentityEnum identityEnum = Arrays.stream(IdentityEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        if (identityEnum == null) {
            throw new ServiceException("IdentityEnum转换错误，不存在的角色码" + code);
        }
        return identityEnum;
    }
}
